<?php

namespace app\api\controller\v1;

use app\api\validate\Count;
use  \app\api\model\Product as ProductModel;
use app\api\validate\IDIntValidate;
use app\lib\exception\ProductException;

class Product
{
    /*
     * 通过指定$id 获取 Product表 数据
     * @http GET
     * @url /theme?ids=id1,id2,id3
     * return  模型
     */
    public function getRecent($count = 15)
    {
        (new Count())->goCheck();
        $products =ProductModel::getMosttRecent($count);
        if($products->isEmpty()){
            throw new ProductException();
        }
        return $products;
    }
    public function getAllInCate($id){//分类商品  基于资源的 之所以放在商品类下
        (new IDIntValidate())->goCheck();
        $products = ProductModel::getProductCateId($id);
        if($products->isEmpty()){
            throw new ProductException();
        }
        return $products;

    }


}
